<?
	  	  include("/inc/header.html") {}
    ?>
	<div class="page-content">
		<div class="row mbl" >
			<div class="col-lg-6">
				<div class="input-group input-group-sm mbs">
					<span class="input-group-btn">
						<select id="queryParams" data-toggle="dropdown" class="btn btn-danger dropdown-toggle" style="width :100px;">
		                    <option value="name_zh">中文名称</option>
		                    <option value="name_en">英文名称</option>
                    	</select>
                   </span> 
                    	<input id="text" type="text" placeholder="请输入关键词..." class="form-control" /><span
						class="input-group-btn"><button type="button"
							data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo(1)">搜索</button>
					</span>
				</div>
			</div>
		</div>
		<div id="dataNull">
			<table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
				<thead>
					<tr>
						<th ><input type="checkbox"></th>
						<th >序号</th>
						<th >中文名称</th>
						<th >英文名称</th>
						<th >描述</th>
						<th >状态</th>
						<th >排序</th>
					</tr>
				</thead>
				<tbody id="findUser">
				</tbody>
			</table>
		</div>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>


<script type="text/javascript">
	function getQueryString(name) { 
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
		var r = window.location.search.substr(1).match(reg); 
		if (r != null) return unescape(r[2]); return null; 
	} 
	var winName=getQueryString("winName");
	var curr;
	var id;
	var ye;
	$(function() {
		demo(1);
	});
	function getId() {
		return id;
	}
	function getCurr() {
		return ye;
	}
	function demo(curr) {
		$.ajax({
			type : "post",
			data : {
				"page" : curr || 1,
				"queryParams":$("#queryParams").val(),
        		"text":$("#text").val(),
        		"number":10
			},
			url : "getCommunityDomainList.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {},
			success : function(data){
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(data[0].count == 0){
					$("#dataNull").html("<div class='subtitle' style='font-size: 15px;text-align: center;'>数据为空!</div>");
				}
				for ( var i = 0; i < data[0].data.length; i++) {
					var status='';
					if(data[0].data[i].status == 0){
						status='正常';
					}else{
						status='禁用';
					}
					str += "<tr><td>"
           		 			+"<input type='checkbox' name='checkall' data-type='"+data[0].data[i].nameZh+"' value='"+data[0].data[i].id+"'/>"
					 		+"</td><td>" 
							+ (i + 1)
							+ "</td><td>"
							+ data[0].data[i].nameZh
							+ "</td><td>"
							+ data[0].data[i].nameEn
							+ "</td><td>"
							+ data[0].data[i].description
							+ "</td><td>"
							+ status
							+ "</td><td>"
							+ data[0].data[i].sort
							+ "</td>"
							+ "</tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : data[0].page, //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: data[0].page,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
							 ye = obj.curr;
			                 curr=obj.curr;
						}
					}
				});
			}
		});
	}
	function save(){
	
		var value=[];
		var name=[];
		$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
			name.push($(this).data("type"));
		});
		if(value.length>1){
			alert('只可单选，请重新选择！');
		}else{
			var index = parent.layer.getFrameIndex(window.name); 
		    window.parent.window[winName].$("#domainNmae").val(name[0]);
		    window.parent.window[winName].$("#domainId").val(value[0]);
		    parent.layer.close(index);
		}
	}
</script>